//
//  LZNavigationController.swift
//  sdxf
//
//  Created by 湛亚磊 on 2020/1/9.
//  Copyright © 2020 湛亚磊. All rights reserved.
//

import UIKit
import RxCocoa
import RxSwift
open class BaseNavigationController: UINavigationController,UINavigationControllerDelegate {
    var popDelegate: UIGestureRecognizerDelegate?
    public override func viewDidLoad() {
        super.viewDidLoad()
        setPopGestureRecognizer()
        
    }
    //设置 手势返回
    private func setPopGestureRecognizer()  {
        self.popDelegate = self.interactivePopGestureRecognizer?.delegate
        self.delegate = self
    }
}

// MARK: - UINavigationControllerDelegate方法
extension BaseNavigationController{
    
    public func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) {

        if viewController == self.viewControllers[0] {
            self.interactivePopGestureRecognizer!.delegate = self.popDelegate
        }
        else {
            self.interactivePopGestureRecognizer!.delegate = nil
        }
    }
}
